from coin.exchange.base.kr_rest.product import NativeProduct
from coin.exchange.gdax.kr_rest.currency import GdaxCurrency
from coin.exchange.gdax.config import group_symbol


class GdaxProduct(NativeProduct):
  _exchange = "Gdax"
  NativeCurrencyType = GdaxCurrency

  def __init__(self, base, quote):
    assert base != quote, (base, quote)
    native_symbol = "%s-%s" % (base.native_currency, quote.native_currency)
    super().__init__(base, quote, native_symbol)

  @classmethod
  def FromStrProductImpl(cls, product, current_datetime):
    assert type(product) == str
    assert '-' in product
    pair = product.split('-')
    assert len(pair) == 2
    base, quote = pair
    base = GdaxCurrency.FromStrCurrency(base)
    quote = GdaxCurrency.FromStrCurrency(quote)
    return GdaxProduct(base, quote)

  @classmethod
  def FromStrNativeProductImpl(cls, product, current_datetime):
    assert type(product) == str
    assert '-' in product
    pair = product.split('-')
    assert len(pair) == 2
    base, quote = pair
    return GdaxProduct.FromStrPairNative(base, quote, current_datetime)
